package belf.migrate.evaluate.model;

import belf.migrate.api.type.DbObjectType;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 内部对象评估结果
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class EvaluateObjectsResult extends EvaluateBaseResult {

    /**
     * 表评估结果
     */
    private EvaluateTableResult tableResult;

    /**
     * 视图评估结果
     */
    private EvaluateViewResult viewResult;

    /**
     * 存储过程评估结果
     */
    private EvaluateProcedureResult procedureResult;

    /**
     * 触发器评估结果
     */
    private EvaluateTriggerResult triggerResult;

    /**
     * 类型评估结果
     */
    private EvaluateTypeResult typeResult;

    /**
     * 索引评估结果
     */
    private EvaluateIndexResult indexResult;

    /**
     * 序列评估结果
     */
    private EvaluateSeqResult seqResult;

    /**
     * 同义词评估结果
     */
    private EvaluateSynonymResult synonymResult;

    /**
     * 函数评估结果
     */
    private EvaluateFunctionResult functionResult;

    /**
     * 内部对象评估耗时
     */
    private String timeConsuming;

    /**
     * 不支持的内部对象类型
     */
    private Map<String, List<DbObjectType>> noSupportObTypesMap;

    public void addNoSupportObTypes(String sinkCatalog, DbObjectType noSupportObType) {
        if (noSupportObTypesMap == null) {
            noSupportObTypesMap = new HashMap<>();
        }
        List<DbObjectType> noSupportObTypes = noSupportObTypesMap.computeIfAbsent(sinkCatalog, k -> new ArrayList<>());
        noSupportObTypes.add(noSupportObType);
        noSupportObTypesMap.put(sinkCatalog, noSupportObTypes);
    }

}
